<extend name="Include:Layout"/>
<block name="title">作业</block>
<block name="style">
<link rel="stylesheet" href="/Public/Assets/player/plyr.css">
<style>
.btn-edit i {margin-right:10px;}
.weui_tabbar_item {padding-bottom:7px;}
.ygcl_desc {color: #999;font-size: 13px;line-height: 1.2;margin-bottom:8px;}
#detail img {width:100%;}
</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_navbar">
			<div class="toolbar">
		        <div class="toolbar-inner">
		            <a href="{:U('home/index/index')}" class="picker-button close-popup">首页</a>
		            <h1 class="title" id="banji_title">详情</h1>
		        </div>
		    </div>
		</div>
		<div class="weui_tab_bd container" id="container" style="padding-top:44px;padding-bottom:45px;">
		    <article class="weui_article" id="detail">
		    	<h4 style="margin-bottom:8px;font-size:18px;">{$info.title}</h4>
		    	<p style="font-size:10px;color:#333">
		    		<if condition="$info['termtime']">
		    		<span style="margin-right:1em">{$info.termtime}</span>
		    		</if>
		    		<span style="margin-right:1em">{$info.create_time}</span>
		    	</p>
		    	
				<p style="font-szie:14px;">{:str_to_html($info['content'])}</p>
		    </article>
		</div>
	</div>
	<div class="weui_tabbar">
     <div class="weui_tabbar_item">
      <div class="weui-row">
      	<div class="weui-col-50"></div>
      	<div class="weui-col-50" style="text-align:center">
      			<a href="javascript:;" data-target="#pingjia" class="weui_btn weui_btn_mini weui_btn_default btn-edit open-popup"><i class="icon iconfont icon-edit"></i><span><if condition="$t">已留言<else/>留言</if></span></a>
      	</div>
       </div>
     </div>
   </div>
<div id="pingjia" class="weui-popup-container">
  	<div class="weui-popup-overlay"></div>
  	<div class="weui-popup-modal">
  		<div class="toolbar">
	        <div class="toolbar-inner">
	            <a href="javascript:;" class="picker-button close-popup">关闭</a>
	            <h1 class="title" id="banji_title">评价课程</h1>
	        </div>
	    </div>
  		<form style="margin-top:60px;">
  			<div class="weui_cells_title">{$info.title}</div>
  			<div class="weui_cells weui_cells_radio">
		        <label class="weui_cell weui_check_label" for="x11">
		            <div class="weui_cell_bd weui_cell_primary">
		                <p>好评</p>
		            </div>
		            <div class="weui_cell_ft">
		                <input type="radio" class="weui_check" name="pingjia" value="好评" id="x11" checked="checked">
		                <span class="weui_icon_checked"></span>
		            </div>
		        </label>
		        <label class="weui_cell weui_check_label" for="x12">
		            <div class="weui_cell_bd weui_cell_primary">
		                <p>中评</p>
		            </div>
		            <div class="weui_cell_ft">
		                <input type="radio" name="pingjia" value="中评" class="weui_check" id="x12">
		                <span class="weui_icon_checked"></span>
		            </div>
		        </label>
		        <label class="weui_cell weui_check_label" for="x13">
		            <div class="weui_cell_bd weui_cell_primary">
		                <p>差评</p>
		            </div>
		            <div class="weui_cell_ft">
		                <input type="radio" name="pingjia" value="差评" class="weui_check" id="x13">
		                <span class="weui_icon_checked"></span>
		            </div>
		        </label>
		    </div>
		    
	        <div class="weui_cells weui_cells_form">
		        <div class="weui_cell">
		            <div class="weui_cell_bd weui_cell_primary">
		                <textarea class="weui_textarea" id="remark" placeholder="请输入评论" rows="3"></textarea>
		            </div>
		        </div>
		    </div>
		    
		    <div style="padding:15px;margin-top:30px;">
		    	<input type="hidden" name="wid" value="{$_GET['id']}"/>
		    	<input type="hidden" name="uid" value="{$_SESSION['_loginUser_home']['uid']}"/>
		    	<a href="javascript:;" class="weui_btn weui_btn_primary pinglun">提交评论</a>
		    </div>
  		</form>
  		<if condition="$t">
  		<volist name="pingjia" id="vo">
  		<div class="weui_panel weui_panel_access">
		  <div class="weui_panel_bd">
		    <div class="weui_media_box weui_media_text">
		      <div class="weui-row">
		      	<div class="weui-col-20"><img src="{$vo.user.headimgurl}" width="100%"/></div>
		      	<div class="weui-col-80">
		      		<h4 class="weui_media_title">{$vo.user.nickname}<span class="ygcl_desc">({$vo.pingjia})</span></h4>
		      		<p class="ygcl_desc">{$vo.remark}</p>
		      		<p class="ygcl_desc">{$vo.create_time} <span><a href="javascript:;" class="pjdel" data-pjid="{$vo.id}">删除</a></span></p>
		      	</div>
		      </div>
		    </div>
		  </div>
		</div>
		</volist>
		</if>
  	</div>
</div>
</block>

<block name="script">
<script>
$(".pjdel").click(function(){
	var that = $(this);
	var data = {
			id: that.attr("data-pjid"),
	}
	$.post('/api/ygcl/delpingjia',data,function(ret){
		if(ret.status){
			$.toast('已删除','text',function(){
				that.parents(".weui_panel").remove();
			});
		}else{
			$.toast('删除失败','text');
		}
	})
})
$(".pinglun").click(function(){
	var pingjia = $('input[name="pingjia"]:checked').val();
	var remark = $("#remark").val();
	var data = {
			uid:$("input[name=uid]").val(),
			wid:$("input[name=wid]").val(),
			pingjia:pingjia,
			remark:remark
	}
	$.post('/api/ygcl/saveworkpingjia',data,function(ret){
		if(ret.status){
			$.toast('提交成功','text',function(){
				location.reload();
			})
		}
	})
})
</script>
</block>